﻿using System;
using System.Collections.Generic;

using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Collections.ObjectModel;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using System.IO;
using System.Drawing;

namespace PPP.Model {
    /// <summary>
    /// Picture properties model with all exif information.
    /// 
    /// <list type="bullet">
    /// <item>
    /// <term>Author</term>
    /// <description>Sebastian Will</description>
    /// </item>
    /// </list>
    /// 
    /// </summary>
    public class PictureProperties {

        #region Fields

        private string _make = string.Empty;
        private string _model = string.Empty;
        private string _orientation = string.Empty;
        private string _artist = string.Empty;
        private string _exposureTime = string.Empty;
        private string _exposureProgram = string.Empty;        
        private string _fNumber = string.Empty;
        private string _aperture = string.Empty;        
        private string _focalLength = string.Empty;
        private string _isoSpeedRatings = string.Empty;
        private string _exposureBias = string.Empty;
        private string _flash = string.Empty;
        private string _xResolution = string.Empty;
        private string _yResolution = string.Empty;
        private string _resolutionUnit = string.Empty;
        private string _software = string.Empty;
        private string _dateTime = string.Empty;
        private string _yCbCrPositioning = string.Empty;
        private string _dateTimeOriginal = string.Empty;
        private string _dateTimeDigitized = string.Empty;
        private string _meteringMode = string.Empty;
        private string _colorSpace = string.Empty;
        private string _focalPlaneXResolution = string.Empty;
        private string _focalPlaneYResolution = string.Empty;
        private string _customRendered = string.Empty;
        private string _exposureMode = string.Empty;
        private string _whiteBalance = string.Empty;
        private string _sceneCaptureType = string.Empty;
        private string _imageUniqueID = string.Empty;
        private string _compression = string.Empty;
        private int _pixelXDimension = 0;
        private int _pixelYDimension = 0;
        private string _xmpToolkit = string.Empty;
        private string _creatorTool = string.Empty;
                
        #endregion        

        #region Properties

        [Category("Information")]
        [DisplayName("Make")]
        [Description("")]
        //Marke
        public string Make {
            get { return _make; }
            set { _make = value; }
        }

        [Category("Information")]
        [DisplayName("Model")]
        [Description("")]
        //Modell
        public string Model {
            get { return _model; }
            set { _model = value; }
        }

        [Category("Information")]
        [DisplayName("Orientation")]
        [Description("")]
        public string Orientation {
            get { return _orientation; }
            set { _orientation = value; }
        }

        [Category("Information")]
        [DisplayName("Artist")]
        [Description("")]
        public string Artist {
            get { return _artist; }
            set { _artist = value; }
        }

        [Category("Information")]
        [DisplayName("Exposure Time")]
        [Description("")]
        //Belichtung
        public string ExposureTime {
            get { return _exposureTime; }
            set { _exposureTime = value; }
        }

        [Category("Information")]
        [DisplayName("Exposure Program")]
        [Description("")]
        //Belichtung
        public string ExposureProgram {
            get { return _exposureProgram; }
            set { _exposureProgram = value; }
        }

        [Category("Information")]
        [DisplayName("FNumber")]
        [Description("")]
        //Blende?
        public string FNumber {
            get { return _fNumber; }
            set { _fNumber = value; }
        }

        [Category("Information")]
        [DisplayName("Aperture")]
        [Description("")]
        //Blende
        public string Aperture {
            get { return _aperture; }
            set { _aperture = value; }
        }

        [Category("Information")]
        [DisplayName("Focal Length")]
        [Description("")]
        //Brennweite
        public string FocalLength {
            get { return _focalLength; }
            set { _focalLength = value; }
        }

        [Category("Information")]
        [DisplayName("ISO Speed Ratings")]
        [Description("")]
        //ISO-Empfindlichkeit
        public string ISOSpeedRatings {
            get { return _isoSpeedRatings; }
            set { _isoSpeedRatings = value; }
        }

        [Category("Information")]
        [DisplayName("Exposure Bias")]
        [Description("")]
        //Belichtungskorrektur
        public string ExposureBias {
            get { return _exposureBias; }
            set { _exposureBias = value; }
        }

        [Category("Information")]
        [DisplayName("Flash")]
        [Description("")]
        //Blitz
        public string Flash {
            get { return _flash; }
            set { _flash = value; }
        }

        [Category("Information")]
        [DisplayName("X-Resolution")]
        [Description("")]
        public string XResolution {
            get { return _xResolution; }
            set { _xResolution = value; }
        }

        [Category("Information")]
        [DisplayName("Y-Resolution")]
        [Description("")]
        public string YResolution {
            get { return _yResolution; }
            set { _yResolution = value; }
        }

        [Category("Information")]
        [DisplayName("Resolution Unit")]
        [Description("")]
        public string ResolutionUnit {
            get { return _resolutionUnit; }
            set { _resolutionUnit = value; }
        }

        [Category("Information")]
        [DisplayName("Software")]
        [Description("")]
        public string Software {
            get { return _software; }
            set { _software = value; }
        }

        [Category("Information")]
        [DisplayName("Date and Time")]
        [Description("")]
        public string DateTime {
            get { return _dateTime; }
            set { _dateTime = value; }
        }

        [Category("Information")]
        [DisplayName("YCbCr Positioning")]
        [Description("")]
        public string YCbCrPositioning {
            get { return _yCbCrPositioning; }
            set { _yCbCrPositioning = value; }
        }

        [Category("Information")]
        [DisplayName("Date and Time (Original)")]
        [Description("")]
        public string DateTimeOriginal {
            get { return _dateTimeOriginal; }
            set { _dateTimeOriginal = value; }
        }

        [Category("Information")]
        [DisplayName("Date and Time (Digitized)")]
        [Description("")]
        public string DateTimeDigitized {
            get { return _dateTimeDigitized; }
            set { _dateTimeDigitized = value; }
        }

        [Category("Information")]
        [DisplayName("Metering Mode")]
        [Description("")]
        public string MeteringMode {
            get { return _meteringMode; }
            set { _meteringMode = value; }
        }

        [Category("Information")]
        [DisplayName("Color Space")]
        [Description("")]
        public string ColorSpace {
            get { return _colorSpace; }
            set { _colorSpace = value; }
        }

        [Category("Information")]
        [DisplayName("Focal Plane X-Resolution")]
        [Description("")]
        public string FocalPlaneXResolution {
            get { return _focalPlaneXResolution; }
            set { _focalPlaneXResolution = value; }
        }

        [Category("Information")]
        [DisplayName("Focal Plane Y-Resolution")]
        [Description("")]
        public string FocalPlaneYResolution {
            get { return _focalPlaneYResolution; }
            set { _focalPlaneYResolution = value; }
        }
        
        [Category("Information")]
        [DisplayName("Custom Rendered")]
        [Description("")]
        public string CustomRendered {
            get { return _customRendered; }
            set { _customRendered = value; }
        }

        [Category("Information")]
        [DisplayName("Exposure Mode")]
        [Description("")]
        public string ExposureMode {
            get { return _exposureMode; }
            set { _exposureMode = value; }
        }

        [Category("Information")]
        [DisplayName("White Balance")]
        [Description("")]
        public string WhiteBalance {
            get { return _whiteBalance; }
            set { _whiteBalance = value; }
        }

        [Category("Information")]
        [DisplayName("Scene Capture Type")]
        [Description("")]
        public string SceneCaptureType {
            get { return _sceneCaptureType; }
            set { _sceneCaptureType = value; }
        }

        [Category("Information")]
        [DisplayName("Image Unique ID")]
        [Description("")]
        public string ImageUniqueID {
            get { return _imageUniqueID; }
            set { _imageUniqueID = value; }
        }

        [Category("Information")]
        [DisplayName("Compression")]
        [Description("")]
        public string Compression {
            get { return _compression; }
            set { _compression = value; }
        }

        [Category("Information")]
        [DisplayName("XMPToolkit")]
        [Description("")]
        public string XMPToolkit {
            get { return _xmpToolkit; }
            set { _xmpToolkit = value; }
        }

        [Category("Information")]
        [DisplayName("Creator Tool")]
        [Description("")]
        public string CreatorTool {
            get { return _creatorTool; }
            set { _creatorTool = value; }
        }

        [Category("Information")]
        [DisplayName("Pixel X Dimension")]
        [Description("")]
        public int PixelXDimension {
            get { return _pixelXDimension; }
            set { _pixelXDimension = value; }
        }

        [Category("Information")]
        [DisplayName("Pixel Y Dimension")]
        [Description("")]
        public int PixelYDimension {
            get { return _pixelYDimension; }
            set { _pixelYDimension = value; }
        }


        

        #endregion


        #region Constructors
        /// <summary>
        /// 
        /// </summary>
        /// <param name="metadata"></param>
        public PictureProperties(Dictionary<string, string> properties) {
            
            //_metadata = image.ImageTag;
            _make = properties["Make"];
            _model = properties["Model"];
            _orientation = properties["Orientation"];
            _exposureTime = properties["ExposureTime"];
            _exposureProgram = properties["ExposureProgram"];            
            _fNumber = properties["FNumber"];
            _aperture = properties["ApertureValue"];
            _focalLength = properties["FocalLength"];
            _isoSpeedRatings = properties["ISOSpeedRatings"];
            _exposureBias = properties["ExposureBiasValue"];
            _flash = properties["Flash"];
            _xResolution = properties["XResolution"];
            _yResolution = properties["YResolution"];
            _resolutionUnit = properties["ResolutionUnit"];
            _software = properties["Software"];
            _dateTime = properties["DateTime"];
            _artist = properties["Artist"];
            _yCbCrPositioning = properties["YCbCrPositioning"];
            _dateTimeOriginal = properties["DateTimeOriginal"];
            _dateTimeDigitized = properties["DateTimeDigitized"];
            _meteringMode = properties["MeteringMode"];
            _colorSpace = properties["ColorSpace"];
            _focalPlaneXResolution = properties["FocalPlaneXResolution"];
            _focalPlaneYResolution = properties["FocalPlaneYResolution"];
            //_focalPlaneYResolution = properties["FocalPlaneResolutionUnit"];
            _customRendered = properties["CustomRendered"];
            _exposureMode = properties["ExposureMode"];
            _whiteBalance = properties["WhiteBalance"];
            _sceneCaptureType = properties["SceneCaptureType"];
            _imageUniqueID = properties["ImageUniqueID"];
            _compression = properties["Compression"];
            _pixelXDimension = int.Parse(properties["PixelXDimension"]);
            _pixelYDimension = int.Parse(properties["PixelYDimension"]);
            //_xmpToolkit = _metadata.Xmp;
            //_creatorTool = string.Empty;
        }

        #endregion
    }
}
